

set scheme s1mono
cd "/Users/jag2367/Documents/GitHub/startup-website-performance/Statistics/Stata"
		
		

global do_ten_fold 1
global do_graphics 1

	
if $do_graphics == 1 {
	do graphics.do
}



use analysis.dta , replace
gen series_aTh = series_a / 1000
label variable series_aTh "Series A Financing (Thousands \\$)"
label variable early_stageTh "Early Stage Financing (Thousands \\$)"
label variable growth "Growth"
label variable gets_series_a "Gets Series A"
eststo clear
estpost summarize website_len early_stageTh  gets_early_stage series_aTh gets_series_a ipo acquired high_value_acq growth  

# delimit ;
	esttab  using ../../tex2/summary_stats.tex , label cells("mean(fmt(%9.3f)) sd(fmt(%9.3g)) min(fmt(%9.1g)) max(fmt(%9.1g))") 
	nonumbers
	prehead("\begin{table}\centering \footnotesize" 
			"\begin{threeparttable}" 
			"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 
			"\caption{ Summary Statistics Crunchbase Firms}" 
			"\begin{tabular}{l*{@M}{ccccccc}} \hline \hline" )	  	
			postfoot("\hline\hline" "\end{tabular}" 
			" \begin{tablenotes} \item {\scriptsize Dataset is all companies in Crunchbase founded since 2003 that raised financing and for whom we where able to download a founding website. Founding website is downloaded from the WaybackMachine as the earliest website available the year after founding. \emph{Early Stage Financing} is defined as all financing that is seed financing, angel financing, or grants. \emph{Website Text Length} is the number of total characters in the downloaded founding website text.}" 
			"\end{tablenotes}" "\end{threeparttable}"  "\end{table}")
			replace
			
;
# delimit cr



clear
use analysis.dta
eststo clear
estpost summarize nov_public_firm_5 nov_startup_5  nov_public_firm_1 nov_startup_1  , detail


esttab , cells("mean(fmt(%9.3f)) sd(fmt(%9.3g)) p10(fmt(%9.1g)) p50(fmt(%9.1g)) p90(fmt(%9.1g)) min(fmt(%9.1g)) max(fmt(%9.1g))") tex label

# delimit ;
	esttab  using    ../../tex2/summary_stats_scores.tex, label cells("mean(fmt(%9.3f)) sd(fmt(%9.3g)) p10(fmt(%9.1g)) p50(fmt(%9.1g)) p90(fmt(%9.1g)) min(fmt(%9.1g)) max(fmt(%9.1g))") 
	nonumbers
	prehead("\begin{table}\centering \footnotesize" 
			"\begin{threeparttable}" 
			"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 
			"\caption{ Summary Statistics of  Strategic Differentiation Score}" 
			"\begin{tabular}{l*{@M}{ccccccc}} \hline \hline" )	  	
			postfoot("\hline\hline" "\end{tabular}" 
			" \begin{tablenotes} \item {\scriptsize Strategic differentiation score represents the conceptual distance in the market between a firm and some of its closest competitors.  It is estimated in three steps.  First, a measure of similarity is estimated between the founding website of all startups in a cohort and the website of all public firms during the startup year of founding.  To do so, we use a word embeddings algorithm that accounts for both the incidence of words and their context. Next, distance is defined as one minus this similarity.  Finally, differentiation is the average distance to the closest competitors.  We report four measures.  The distance to the five closest incumbent firms (public firms). Distance to the single closest public firm.  Distance to the five closest startups from the same cohort. And distance to the single closest startup in the same cohort. All code is available at https://github.com/jorgeguzmanecon/measuring-founding-strategy.}" 
			"\end{tablenotes}" "\end{threeparttable}"  "\end{table}")
			replace
			
;
# delimit cr



/*
corrtex  nov_public_firm_5 nov_public_firm_1 nov_startup_5 nov_startup_1 , file("../../tex2/correlations.tex") replace


estpost correlate  nov_public_firm_5 nov_public_firm_1 nov_startup_5 nov_startup_1  , matrix

eststo clear
estpost correlate  nov_public_firm_5 nov_public_firm_1 nov_startup_5 nov_startup_1  , matrix
 esttab using ../../tex2/correlations.tex, unstack b(2)  noobs nostar    replace  title("Correlation of Differentiation Scores") tex label  

*/


	/***
	
		No
	****/


	clear
	use analysis.dta




	eststo clear
	eststo: reghdfe gets_early_stage nov_public_firm_5  ,   noabsorb cluster(hp_ind state) 
	eststo: reghdfe gets_early_stage nov_public_firm_5   ,  absorb(year) cluster(hp_ind state) nocons
	eststo: reghdfe gets_early_stage nov_public_firm_5   ,  absorb( year hp_ind ) cluster(hp_ind state) nocons keepsingleton
	eststo: reghdfe gets_early_stage nov_public_firm_5   ,  absorb( year#statecode year#hp_ind citycode ) cluster(hp_ind state) nocons keepsingleton
	esttab ,p
	estfe est*, labels(year "Founding Year F.E." hp_industry "HP Industry F.E."   citycode "City F.E.")

	esttab, se r2  drop( *_cons)

	
	
	# delimit ; 

		esttab using ../../tex2/nov5_on_gets_early_stage.tex, 
			se r2  indicate(   "Founding Year F.E.=0.year"     "HP Industry F.E.=0.h*" "Year $\times$ State F.E.=0.year#0.statecode"  "City F.E.=0.citycode" ) drop( *_cons)
		label
		nomtitle
		star(* .1 ** .05 *** .01)
	prehead("\begin{table}\centering \footnotesize" 
			"\begin{threeparttable}" 
			"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 
			"\caption{ Does founding differentiation predict the receipt early stage financing? }" 
			"\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	
			postfoot("\hline\hline" "\end{tabular}" 
			" \begin{tablenotes} \item {\scriptsize OLS  linear probability model. Dependent variable is equal to 1 if a startup gets early stage financing (seed or angel financing) and zero otherwise. HP Industry fixed effects are fixed effects for 300 industries created by replicating the text-based industry approach of Hoberg \& Phillips (2016) within our website data. Standard errors double clustered by HP industry and state. Significance reported as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01.}" 
			"\end{tablenotes}" "\end{threeparttable}"  "\end{table}")
			replace
			
	;
	# delimit cr




clear
use analysis.dta 

eststo clear
eststo: reghdfe log_early_stage nov_public_firm_5   ,  noabsorb cluster(hp_ind state) keepsingleton
eststo: reghdfe log_early_stage nov_public_firm_5   ,  absorb(year) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_early_stage nov_public_firm_5   ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_early_stage nov_public_firm_5   ,  absorb( year#statecode year#hp_ind  citycode) cluster(hp_ind state) keepsingleton


eststo: reghdfe log_seed nov_public_firm_5   ,  absorb( year hp_ind) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_grant nov_public_firm_5   ,  absorb( year hp_ind) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_angel nov_public_firm_5   ,  absorb( year hp_ind) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_up_to_a nov_public_firm_5   ,  absorb( year hp_ind) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_series_a nov_public_firm_5 if gets_early_stage == 0 ,  absorb( year hp_ind) cluster(hp_ind state) keepsingleton

esttab , p


estfe est*, labels(year "Founding Year F.E." hp_industry "HP Industry F.E." year#statecode "Year X State F.E."  citycode "City F.E.")
//esttab, se r2  indicate(`r(indicate_fe)') drop(source _cons)
# delimit ; 

	esttab using ../../tex2/nov5_on_log_early_stage.tex, 
		se r2  indicate(  "Founding Year F.E.=0.year"  "HP Industry F.E.=0.h*"    "Year by State F.E.=0.year#0.statecode" "City F.E.=0.citycode" ) drop( *_cons)
	label
		star(* .1 ** .05 *** .01)
	nocons
	mtitles("\makecell{\emph{Dep. Var.}\\Early Stage}" 
			"\makecell{\emph{Dep. Var.}\\Early Stage}" 
			"\makecell{\emph{Dep. Var.}\\Early Stage}" 
			"\makecell{\emph{Dep. Var.}\\Early Stage}"  
			"\makecell{\emph{Dep. Var.}\\Seed}"  
			"\makecell{\emph{Dep. Var.}\\Grant}"  
			"\makecell{\emph{Dep. Var.}\\Angel}"  
			"\makecell{\emph{Dep. Var.}\\Series A + \\Early Stage}" 
			"\makecell{\emph{Dep. Var.}\\Series A\\\emph{Subsample}\\Firms without \\ Early Stage }" )
prehead("\begin{table}\centering \footnotesize" 
		"\begin{threeparttable}" 
		"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 
		"\caption{ Does founding differentation predict the amount of early stage financing? }" 
		"\begin{tabular}{l*{@M}{ccccccc}} \hline \hline" )	  	
		postfoot("\hline\hline" "\end{tabular}" 
		" \begin{tablenotes} \item {\scriptsize OLS model. Dependent variable is the log of total fundraised in early stage financing plus 1. HP Industry fixed effects are fixed effects for 300 industries created by replicating the text-based industry approach of Hoberg \& Phillips (2016) within our website data. Standard errors double clustered by HP industry and state. Column (7) is the Series A fundraising only for companies that  did not raise early stage financing. Significance reported as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01.}" 
		"\end{tablenotes}" "\end{threeparttable}"  "\end{table}")
		replace
		
;
# delimit cr


clear
use analysis.dta 
eststo clear
eststo: reghdfe log_early_stage c.nov_public_firm_5   ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_early_stage c.nov_public_firm_1   ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_early_stage c.nov_startup_5   ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_early_stage c.nov_startup_1   ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_early_stage c.nov_public_firm_5 nov_public_firm_1   ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_early_stage nov_public_firm_5 nov_startup_5   , absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_early_stage nov_public_firm_1 nov_startup_1   , absorb( year hp_ind ) cluster(hp_ind state) keepsingleton

esttab

estfe est*, labels(year "Year F.E." hp_industry "HP Industry F.E.")

# delimit ; 
	esttab using ../../tex2/other_outcomes_log_early_stage.tex, 
		se r2  indicate("Founding Year F.E. = 0.year" 
						"HP Industry F.E.=0.hp_industry"  ) 
		drop( *_cons)
	label
	nomtitle 
	nocons order(nov_public_firm_5 nov_public_firm_1 nov_startup_5 nov_startup_1)
prehead("\begin{table}\centering \footnotesize" 
		"\begin{threeparttable}" 
		"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 
		"\caption{Other measures of founding differentiation and early stage financing.}" 
		"\begin{tabular}{l*{@M}{ccccccc}} \hline \hline" )	  	
		postfoot("\hline\hline" "\end{tabular}" 
		" \begin{tablenotes} \item {\scriptsize OLS model. Dependent variable is the log of total fundraised in early stage financing plus 1. HP Industry fixed effects are fixed effects for 300 industries created by replicating the text-based industry approach of Hoberg \& Phillips (2016) within our website data. Standard errors double clustered by HP industry and state. Significance reported as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01.}" 
		"\end{tablenotes}" "\end{threeparttable}"  "\end{table}")
		replace
		
;
# delimit cr



	clear 
	use analysis.dta 


	eststo clear
	eststo: reghdfe growth nov_public_firm_5   ,  absorb(year) cluster(hp_ind state) keepsingleton
	eststo: reghdfe growth nov_public_firm_5  ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
	eststo: reghdfe growth nov_public_firm_5   ,  absorb(i.year#i.statecode  hp_ind  citycode ) cluster(hp_ind state) keepsingleton
	
	eststo: reghdfe ipo nov_public_firm_5   ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
	eststo: reghdfe acquired nov_public_firm_5   ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
	
	
	esttab , p
	//esttab ,   cells(b(fmt(%12.3fc) star) se(fmt(%12.3fc)) p(fmt(%4.3f))) star(* .1 ** .05)


	estfe est*, labels(year "Year F.E." hp_industry "HP Industry F.E." year#statecode "Year X State F.E." city "City F.E.")

	# delimit ; 

		esttab using ../../tex2/nov5_on_equity_growth.tex, 
			se r2 indicate( "Founding Year  F.E.=0.year"    "HP Industry F.E.=0.hp_industry"   "Year $\times$ State F.E.=0.year#0.statecode" "City F.E.=0.citycode" )   drop( *_cons)
		label
		mtitles("\makecell{\emph{Dep. Var.} \\ IPO or Acq.}" "\makecell{\emph{Dep. Var.} \\ IPO or Acq.}" "\makecell{\emph{Dep. Var.} \\ IPO or Acq.}"    "\makecell{\emph{Dep. Var.} \\ IPO}"  "\makecell{\emph{Dep. Var.} \\ Acquisition}")
		
		nocons 
		 star(* .1 ** .05)
	prehead("\begin{table}\centering \footnotesize" 
			"\begin{threeparttable}" 
			"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 
			"\caption{ Does founding differentiation predict equity performance? }" 
				"\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	
			postfoot("\hline\hline" "\end{tabular}" 
			" \begin{tablenotes} \item {\scriptsize OLS model. Dependent variable is a binary variable equal to 1 if a firm is IPO or acquired and zero otherwise. HP Industry fixed effects are fixed effects for 300 industries created by replicating the text-based industry approach of Hoberg \& Phillips (2016) within our website data. Standard errors double clustered by HP industry and state. Significance reported as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01.}"
			"\end{tablenotes}" "\end{threeparttable}"  "\end{table}")
			replace
			
	;
	# delimit cr

	
	
	
	
clear 
use analysis.dta 

	

label variable log_early_stage "Log(Early Stage + 1)"
gen log_price = log(acq_price) 




eststo clear

eststo: reghdfe growth nov_public_firm_5  if year < 2012,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
eststo: reghdfe early_acq nov_public_firm_5  ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
eststo: reghdfe late_acq nov_public_firm_5  ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
eststo: reghdfe log_price nov_public_firm_5  ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
eststo: reghdfe high_value_acq nov_public_firm_5  ,  absorb( year hp_ind ) cluster(hp_ind state) keepsingleton
	
esttab , p 
estfe est*


# delimit ; 

	esttab using ../../tex2/nov5_on_equity_growth_control_for_vc.tex, 
		se r2 indicate("Founding Year F.E. = 0.year" 
						"HP Industry F.E.=0.hp_industry"   ) 
	label
	mtitles("\makecell{\emph{Subsample:}\\ Drop Firms \\ Founded 2012 \\or Later}" 
	"\makecell{\emph{Dep. Var.} \\ IPO or Acq. \\ During First \\ 5 Years}" 
	"\makecell{\emph{Dep. Var.} \\ IPO or Acq. \\ After First \\ 5 Years}" 
	"\makecell{\emph{Dep. Var.} \\Log(Acq. Price)}"
"\makecell{\emph{Dep. Var.} \\High Value \\ Acq.}")
	nocons drop( _cons)  
	 star(* .1 ** .05)
prehead("\begin{table}\centering \footnotesize" 
		"\begin{threeparttable}" 
		"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 
		"\caption{Founding differentiation and equity performance }" 
		"\begin{tabular}{l*{@M}{ccccccc}} \hline \hline" )	  	
		postfoot("\hline\hline" "\end{tabular}" 
	" \begin{tablenotes} \item {\scriptsize OLS model. Dependent variable is a binary variable equal to 1 if a firm is IPO or acquired and zero otherwise. HP Industry fixed effects are fixed effects for 300 industries created by replicating the text-based industry approach of Hoberg \& Phillips (2016) within our website data. Standard errors double clustered by HP industry and state. Significance reported as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01.}"
				"\end{tablenotes}" "\end{threeparttable}"  "\end{table}")
		replace
		
;
# delimit cr






eststo clear
eststo: reghdfe growth nov_public_firm_5   ,  absorb(year hp_ind) cluster(hp_ind state)
eststo: reghdfe growth nov_public_firm_1   ,  absorb(year hp_ind) cluster(hp_ind state)
eststo: reghdfe growth nov_startup_5   ,  absorb(year hp_ind) cluster(hp_ind state)
eststo: reghdfe growth nov_startup_1   ,  absorb(year hp_ind) cluster(hp_ind state)
eststo: reghdfe growth nov_public_firm_5 nov_public_firm_1   ,  absorb(year hp_ind ) cluster(hp_ind state)
eststo: reghdfe growth nov_public_firm_5 nov_startup_5   , absorb(year hp_ind) cluster(hp_ind state)
eststo: reghdfe growth nov_public_firm_1 nov_startup_1   , absorb(year hp_ind) cluster(hp_ind state)


estfe est*, 
esttab 

 # delimit ; 

 	esttab using ../../tex2/nov5_on_equity_growth_robustness.tex, 
 		se r2  indicate("Founding Year F.E. = 0.year" 
						"HP Industry F.E.=0.hp_industry" ) 
 	label
 	nocons star(* .1 ** .05)
 	nomtitle
 prehead("\begin{table}\centering \footnotesize" 
 		"\begin{threeparttable}" 
 		"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 
 		"\caption{ Other measures of founding differentiation and equity performance. }" 
 		"\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	
 		postfoot("\hline\hline" "\end{tabular}" 
 		" \begin{tablenotes} \item {\scriptsize OLS model. Dependent variable is a binary variable equal to 1 if a firm is IPO or acquired and zero otherwise. HP Industry fixed effects are fixed effects for 300 industries created by replicating the text-based industry approach of Hoberg \& Phillips (2016) within our website data. Standard errors double clustered by HP industry and state. Significance reported as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01.}" 
 		"\end{tablenotes}" "\end{threeparttable}"  "\end{table}")
 		replace
	
 ;
 # delimit cr



/****************************** Panel Analysis *******************************/





clear 
use analysis.dta 
duplicates drop website , force

forvalues t = 0/20 {
	gen ipo_by_`t' = (ipo_year - year) <= `t' & ipo_year != .
	gen acq_by_`t' = (acq_year - year) <= `t' & acq_year != .
	gen growth_by_`t' = ipo_by_`t'==1 | acq_by_`t'==1
	gen hvacq_by_`t' = (acq_year - year) <= `t' & high_value_acq
}


gen id = _n
keep hp_ind id  ipo_by_* acq_by_* year ind growth_by_* hvacq_by_* source   nov_public_firm_5 nov_startup_5 bio finance nov_public_firm_1 text_len  statecode founding_year  website_len text_words wlbin
reshape long ipo_by_ acq_by_ hvacq_by_ growth_by_, i(id) j(t)



xtset id t
gen growth_cum = growth_by_
gen ipo_cum = ipo_by_
gen acq_cum = acq_by_
gen hvacq_cum = hvacq_by_



drop if t > 11
gen obs_year = year + t
drop if obs_year >= 2018

gen age = obs_year - year
save analysis.panel.dta , replace




set scheme s1mono
use analysis.panel.dta , replace

label variable t "Age"



eststo clear
eststo: reghdfe growth_cum  c.nov_public_firm_5#i.t  ,  absorb(  year hp_ind ) cluster( hp_ind state )  nocons
eststo: reghdfe ipo_cum  c.nov_public_firm_5#i.t ,  absorb(    year hp_ind ) cluster( hp_ind state  )   nocons
eststo: reghdfe acq_cum  c.nov_public_firm_5#i.t ,  absorb(  year hp_ind) cluster( hp_ind state )   nocons
eststo: reghdfe hvacq_cum  c.nov_public_firm_5#i.t  ,  absorb(  year hp_ind) cluster( hp_ind state )   nocons
esttab, label p





estfe est*, labels(year "Year F.E." hp_industry "HP Industry F.E.")


# delimit ; 

	esttab using ../../tex2/age_coefficients.tex, 
				se r2 indicate("Founding Year F.E.=0.year"
								"Hp Industry F.E.=0.hp_industry") 
order(nov_public_firm_5)
	label
	nocons star(* .1 ** .05)
	mtitle("\makecell{\emph{Dep. Var.} \\ IPO or Acq.\\ (Cumulative)}" "\makecell{\emph{Dep. Var.} \\ IPO\\ (Cumulative)}" 
	"\makecell{\emph{Dep. Var.} \\ Acquisition\\ (Cumulative)}"
	"\makecell{\emph{Dep. Var.} \\High Value Acquisition\\ (Cumulative)}"
	)
prehead("\begin{table}\centering \footnotesize" 
		"\begin{threeparttable}" 
		"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 
		"\caption{ Dynamic effects of founding differentiation on equity performance across age. }" 
		"\begin{tabular}{l*{@M}{ccccccc}} \hline \hline" )	  	
		postfoot("\hline\hline" "\end{tabular}" 
		" \begin{tablenotes} \item {\scriptsize OLS model. Dependent variable is a binary variable equal to 1 if a firm has achieved IPO or acquired by age \emph{t} and zero otherwise. Standard errors double clustered by HP industry and state. Significance reported as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01.}" 
		"\end{tablenotes}" "\end{threeparttable}"  "\end{table}")
		replace
		
;
# delimit cr
